﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Edutainment
{
    public class SortationController
    {
        public SortAlgorithm currentSortAlgorithm {get; set;}
        public BubbleSort bubbleSort {get; set;}
        public MergeSort mergeSort { get; set;}

        public SortationController()
        {
            currentSortAlgorithm = null;
            bubbleSort = new BubbleSort();
            mergeSort = new MergeSort();
        }

        public SortationController(ArrayList lastState)
        {
            currentSortAlgorithm = null;
            foreach (SortAlgorithm algo in lastState)
            {
                if (algo is BubbleSort)
                    bubbleSort = algo as BubbleSort;
                else if (algo is MergeSort)
                    mergeSort = algo as MergeSort;
            }
        }

        public void prepareBubbleSort(int count, bool isExam)
        {
            //bubbleSort.restart();

            int numbersCount = 8;

            if (count > 0)
                numbersCount = count;

            bubbleSort.createListToSort(numbersCount, isExam);
            currentSortAlgorithm = bubbleSort;
        }

        public void prepareMergeSort(int count, bool isExam)
        {
            //mergeSort.restart();

            int numbersCount = 8;

            if (count > 0)
                numbersCount = count;

            mergeSort.createListToSort(numbersCount, isExam);
            currentSortAlgorithm = mergeSort;
        }

    }
}
